<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/3/29 0029
 * Time: 16:03
 */

namespace app\home\controller;
use think\Db;


class Venues extends Base
{
        public function index(){
            //广告
            $data_banner = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and type=6')->order('sort desc,id desc')->field('banner_img,out_link')->find();
            $this->assign('data_banner',$data_banner);
            //拍摄基地
            $Scenery = intval(input('param.Scenery'));
            $where='is_del=0 and is_show=1 and sign="pc"';
            if($Scenery){
                $where .=' and Scenery = '.$Scenery;
                $this->assign('Scenery',$Scenery);
            }else{
                $where .=' and Scenery =2';
                $this->assign('Scenery',2);
            }
            $data_jd = Db::name('psjd')->where($where)->order('sort desc,id desc')->field('id,main_img,title,intro,Scenery')->limit(4)->select();
            $this->assign('data_jd',$data_jd);
            $next_data = Db::name('psjd')->where($where)->order('sort desc,id desc')->field('id,main_img,title,intro,Scenery')->page(2,4)->select();
            $type = 1;
            if(!$next_data){
                $type = 2;
            }
            $this->assign('type',$type);
            //场馆基地(顶部导航推荐)
            $data_cg = Db::name('psjd')->where('is_del=0 and is_show=1 and sign="pc" and is_recom=1')->order('sort desc,id desc')->select();
            $this->assign('data_cg',$data_cg);
            $this->assign('data_seo',getColumnseo(4));
            return $this->fetch();
        }

    public function nr(){
        $id = intval(input('param.id'));
        if($id){
            $data = Db::name('psjd')->where('id',$id)->find();
            $this->assign('data',$data);
        }
        //场馆基地(顶部导航推荐)
        $data_cg = Db::name('psjd')->where('is_del=0 and is_show=1 and sign="pc" and is_recom=1')->order('sort desc,id desc')->select();
        $this->assign('data_cg',$data_cg);
        $this->assign('data_seo',getColumnseo(4));
        return $this->fetch();
    }


    public  function  getmore(){
        $where ='is_del=0 and is_show=1 and sign="pc"';
       $scenery = intval(input('param.scenery'));
        $page = intval(input('post.page'));
        if($scenery){
            $where .=' and Scenery='.$scenery;
        }
        $data = Db::name('psjd')->where($where)->page($page,4)->select();
        //判断下一页是否有数据
        $next_page = $page+1;
        $next_data = Db::name('psjd')->where($where)->order('sort desc,id desc')->page($next_page,4)->select();
        $type = 1;
        if(!$next_data){
            $type = 2;
        }

        if($data){
            return json(['code'=>1,'data'=>$data,'type'=>$type]);
        }else{
            return json(['code'=>0,'msg'=>'没有更多了']);
        }




    }
}